package com.woniuxy.service.impl;

import com.woniuxy.entity.User;
import com.woniuxy.mapper.AuthMapper;
import com.woniuxy.service.AuthService;
import com.woniuxy.utils.JWTUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Author: 马宇航
 * @Todo: TODO
 * @DateTime: 25/08/06/星期三 12:16
 * @Component: 成都蜗牛学苑
 **/
@Service
public class AuthServiceImpl implements AuthService {
    @Autowired
    AuthMapper authMapper;
    @Autowired
    RedisTemplate redisTemplate;
    @Override
    public User login(User user) {
        //先通过用户名查询用户
        User loginUser = authMapper.findByUsername(user.getUsername());
        //再代码中比较密码，然后生成token
        if (loginUser == null) {
            return null;
        }else {
            //密码是要加密的
            if (user.getPassword().equals(loginUser.getPassword())) {
                //密码正确，生成token
                return user;
            }else {
                return null;
            }
        }
    }
}
